'use strict';

module.exports = app => {
    return class RedirectService extends app.Service {
        constructor(ctx) {
            super(ctx);
        }

        async im({ url, params = {}, method = 'POST'}) {
            const result = await this.ctx.fetch(this.config.api.im + url, {
                method: method,
                dataType: 'json',
                data: params
            });

            this.app.logger.info(result.data);

            return result.data;
        }

        async guardian({ url, params = {}, method = 'POST'}) {
            const result = await this.ctx.fetch(this.config.api.base + url, {
                method: method,
                dataType: 'json',
                data: params
            });

            this.app.logger.info(result.data);

            return result.data;
        }

    }
};
